package com.binguo.api.controller;

import com.binguo.api.result.Result;
import com.binguo.api.result.ResultGenerator;
import com.binguo.common.enums.FileUpload;
import com.binguo.service.LogSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
public class DeviceLogController{

    @Autowired
    private LogSaveService logSaveService;


    @PostMapping(value = "/api/log/uploadFile")
    public Result LogfileUpload(MultipartFile file,  Integer deviceId){
        FileUpload fileUpload = logSaveService.UploadLogFile(file,deviceId);
        if(fileUpload.getCode() == 1){
            return ResultGenerator.genSuccessResult("保存成功");
        }else{
            return ResultGenerator.genFailResult(fileUpload.getMsg());
        }

    }
}
